Skip to content

Conversation

@iloveitaly
Copy link
Contributor

Fixes #18

Previously, TypeID.repr() returned TypeID('prefix_suffix') which was not valid Python code since the constructor doesn't accept strings directly. This made it impossible to copy-paste TypeID representations from error messages or interactive sessions.

Now repr() returns TypeID.from_string('prefix_suffix'), making the output directly executable and copy-pasteable into Python interpreters.

All existing tests pass with this change.

Fixes akhundMurad#18

Previously, TypeID.__repr__() returned TypeID('prefix_suffix') which
was not valid Python code since the constructor doesn't accept strings
directly. This made it impossible to copy-paste TypeID representations
from error messages or interactive sessions.

Now __repr__() returns TypeID.from_string('prefix_suffix'), making the
output directly executable and copy-pasteable into Python interpreters.

All existing tests pass with this change.
Copy link
Owner

@akhundMurad akhundMurad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akhundMurad akhundMurad merged commit d0208fc into akhundMurad:main Nov 20, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add .from_string to __repr__

3 participants